﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Services;


public partial class Palestras_GerenciarPalestra : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["Usuario"] == null || Session["TipoUsuario"] == null)
            Response.Redirect("../Login.aspx");
        if (Session["Evento"] == null)
            Response.Redirect("../DefaultAG.aspx");
        if (Session["TipoUsuario"].ToString() != "Administrador Geral")
            Response.Redirect("../Default.aspx");
    }
    protected void buttonNovaPalestra_Click(object sender, EventArgs e)
    {
        Response.Redirect("~/Palestra/CadastrarPalestra.aspx");
    }
    [WebMethod(EnableSession=true)]
    public static Resultado<Palestra> getPalestras(int pagina)
    {
        int pag = pagina - 1;
        int i = pag * 4;
        DataClassesDataContext dc = new DataClassesDataContext();
        Resultado<Palestra> retorno = new Resultado<Palestra>();
        retorno.Data = dc.Palestras.OrderBy(p => p.idEvento.Equals(new Guid(System.Web.HttpContext.Current.Session["Evento"].ToString()))).Skip(i).Take(4).ToList();
        retorno.TotalCount = dc.Palestras.Count();
        return retorno;
    }
    [WebMethod]
    public static bool excluir(string idPalestra)
    {
        return Palestra.excludePalestra(new Guid(idPalestra));
    }
}